package com.wise.site.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;

import com.wise.site.R;
import com.wise.site.protocol.action.ImageItemsAction;
import com.wise.site.protocol.base.ProtocolManager;
import com.wise.site.protocol.base.SoapItem;
import com.wise.site.protocol.base.SoapAction.ACTION_TYPE;
import com.wise.site.protocol.base.SoapAction.ActionListener;
import com.wise.site.protocol.result.ImageItem;
import com.wise.site.protocol.result.ImageItemsResult;

public class SaleImageAdapter extends ArrayListAdapter<SoapItem> {
	private LayoutInflater mInflater;

	public SaleImageAdapter(Context context) {
		super(context);
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView = mInflater.inflate(R.layout.sale_view_image, null);
		ImageView image = (ImageView) convertView.findViewById(R.id.image);
		ImageItem item = (ImageItem) mList.get(position);
		//根据图片地址组装成图片
		image.setImageResource(Integer.parseInt(item.iconURL));
		return convertView;
		
	}
	
	public void loadData() {
		ImageItemsAction action = new ImageItemsAction(ACTION_TYPE.ACTION_COMMON, "getImageItems");
		action.setActionListener(new ActionListener<ImageItemsResult>() {

			@Override
			public void onSucceed(ImageItemsResult result) {
				setList(result.getList());
				
			}

			@Override
			public void onError(int resultCode) {
				// TODO Auto-generated method stub
				//refenceComplete();
			}
		});
		ProtocolManager.getProtocolManager().submitAction(action);
	}

	@Override
	public void moveToNextPage() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void moveToFristPage() {
		// TODO Auto-generated method stub
		
	}

}
